NVM.Accordion = function () {
    var __core = NOVEM.Core;

    return {
        init: function (selector) {
            selector = __core.getSelector(selector, false);
            if (selector.length < 1) {
                return true;
            }

            // let elements = selector;
            selector.forEach(function (accordion) {
                let elements = accordion.querySelectorAll('.accordion-item');
                [...elements].map(ele => {
                    const title = ele.querySelector('.accordion-title');
                    ele.classList.remove('active');
                    const content = ele.querySelector('.accordion-content');
                    content.style.height = '0';
                    title.addEventListener('mouseover', () => {
                        const isActive = ele.classList.contains('active');
                        [...elements].forEach(otherEle => {
                            if (otherEle !== ele) {
                                otherEle.classList.remove('active');
                                otherEle.querySelector('.accordion-content').style.height = '0';
                            }
                        });
                        if (isActive) {
                            ele.classList.remove('active');
                            content.style.height = '0';
                        } else {
                            ele.classList.add('active');
                            content.style.height = content.scrollHeight + 'px';
                        }
                    });
                });
            })



        }
    };
}();
